package com.cskaoyan.dbutils;

import com.cskaoyan.others.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.SQLException;

/**
 * 创建日期: 2021/11/25 16:30
 *
 * @author ciggar
 */
public class ScalarHandlerDemo {

    public static void main(String[] args) throws SQLException {

        // 1. 创建QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        // 2. 执行SQL语句
        // 查询余额大于10000 的人数
        Long count = queryRunner.query("select count(*) from account where money > 5000", new ScalarHandler<Long>());

        System.out.println(count);

    }

}
